#include "stdio.h"
#include "stdlib.h"
void quickSort(int *number, int first, int last) {
	int i, j, pivot;
	int temp;
	if (first<last) {
		pivot = first;
		i = first;
		j = last;
		while (i<j) {
			while (number[i] <= number[pivot] && i<last)
				i++;
			while (number[j]>number[pivot])
				j--;
            //number[j] <= number[pivot]
            //number[i] > number[pivot]
			if (i<j) {
				temp = number[i];
				number[i] = number[j];
				number[j] = temp;
			}
		}
		temp = number[pivot];
		number[pivot] = number[j];
		number[j] = temp;
		quickSort(number, first, j - 1);
		quickSort(number, j + 1, last);
	}
}

void swap(int a, int b)
{
	int t = a;
	a = b; 
	b = t;
}
void mysort(int *a, int first, int last){
	int i, j, privot;
	int k;
    if(first < last) {
        i = first;
        j = last;
        privot = first;
        k = a[privot];
        while (i < j)
        {
            while(a[j] > k)
                j--;
            while ((a[i] <= k) && (i < last))
                i++;
            //a[j] <=temp, a[i] >temp
            if (i < j) {
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
        //需要继续重排
        k = a[j];
        mysort(a, first, j-1);
        mysort(a, j+1, last);

    }

}
int main() {
    int a[]={1,3,2,7,5,9};
    quickSort(a, 0, 5);
    for (size_t i = 0; i < (sizeof(a)/sizeof(a[0])); i++)
    {
        printf("%d-",a[i]);
    }
    return 0;
}